<?php
//exit();
set_time_limit(0);
$_isDBExist = "no";
$_DBSite = "Master";
global $_Conn124;
global $_ConnMaster;
$_BetDBHost = "192.168.5.124";
$_BetDBUser = "kacino";
$_BetDBPass = "cyriac_0426";
if (! $_Conn124 = @mysql_connect($_BetDBHost, $_BetDBUser, $_BetDBPass)) {
	$email = "service@".$_BetWeb;
	$subject = " mysql_connect error (".$_BetWeb.")";
	$content = "連線錯誤：無法連線至資料庫主機！\nDBSite".$_DBSite."\nPage: ".$_SERVER["PHP_SELF"]."\n";
	if($_isDBExist == "no"){
		$_strLogErr = $content."<br />\n";
		mail($email, $subject, $content, "From:".$_BetWeb."<apache@secure.".$_BetWeb.">");
		exit($_strLogErr);
	}
}
mysql_query("SET NAMES 'utf8'", $_Conn124);

$_Conn = "_ConnMaster";
$strDate = date("Y-m-d");
include("AllWeb.inc.php");

$strMailCon = "";
if (!defined('__Modules_Path')) define('__Modules_Path', '/home/share/www/SourceSite-utf8/secure/modules');
foreach($arrWeb as $strWeb){
	$_strLogErr = "";
	$_blDBName = "";
	$_ConnMaster = null;
	if($strWeb == "luckyball.cc")continue;
	if($strWeb == "3d.usbet33.us")continue;
	$strMailCon .= "\n\n".$strWeb."<br />\n==============================================<br />\n";

	$_SERVER["DOCUMENT_ROOT"] = "/home/share/www/".$strWeb."/secure";
	if(!file_exists($_SERVER["DOCUMENT_ROOT"]."/db.inc.php"))continue;
	include($_SERVER["DOCUMENT_ROOT"]."/db.inc.php");
	if($_strLogErr != ""){
		$strMailCon .= $_strLogErr."<br />\n\n";
		continue;
	}
	if($_blDBName == "")continue;

	$strMailCon .= "$_blDBName  $_blDBHostM  (Time: ".date("Y-m-d H:i:s").")<br />\n\n";

	if(!mysql_select_db($_blDBName, $_Conn124)){
		$strMailCon .= "LogRecord Error :".mysql_error($_Conn124)."<br />\n";
		continue;
	}

	$strSQL = "select MAX(ID) as MaxID, MIN(ID) as MinID, COUNT(*) as tolWager, SUM(MemResult) as tolResult from `bet_BetList` where PayupDate between '2008-10-01' and '2009-01-30'";

	$intMinID_124 = 0;
	if(!$RS = mysql_query($strSQL, $_Conn124)){
		$strMailCon .= "124 => Member Find Error :".mysql_error($_Conn124)."<br />\n";
	}else{
		$Rows = mysql_fetch_object($RS);
		$strMailCon .= "124 => MaxID: ".$Rows -> MaxID."  MinID: ".$Rows -> MinID."   tolWager :".$Rows -> tolWager."   tolResult :".$Rows -> tolResult."<br />\n";
		$intMinID_124 = $Rows -> MinID;
	}

	$intMinID_Mst = 0;
	if(!$RS = PMA_mysql_query($strSQL, $_ConnMaster)){
		$strMailCon .= "Mst => Member Find Error :".PMA_mysql_error($_ConnMaster)."<br />\n";
	}else{
		$Rows = PMA_mysql_fetch_object($RS);
		$strMailCon .= "Mst => MaxID: ".$Rows -> MaxID."  MinID: ".$Rows -> MinID."   tolWager :".$Rows -> tolWager."   tolResult :".$Rows -> tolResult."<br />\n";
		$intMinID_Mst = $Rows -> MinID;
	}

}
//print "End (".date("Y-m-d H:i:s").")<br />\n\n";
$strMailCon .= "End (".date("Y-m-d H:i:s").")<br />\n\n";

print $strMailCon;
?>